package cn.ichiva.tushare.analysis.data.国内宏观.价格指数;

import cn.ichiva.tushare.analysis.Config;
import cn.ichiva.tushare.analysis.data.国内宏观.金融.CNM;
import cn.ichiva.tushare.sdk.tushare.TuClient;
import cn.ichiva.tushare.sdk.tushare.TuDataCacheAble;
import cn.ichiva.tushare.sdk.tushare.entity.TuRequest;

import java.util.HashMap;
import java.util.LinkedHashMap;

/**
 * 工业生产者出厂价格指数
 *
 * 获取2000年到现在的所有数据
 */
public class PPI extends TuDataCacheAble {

    public PPI(TuClient client) {
        super(client);

        TuRequest request = new TuRequest();
        request.setApi("cn_ppi");
        request.setDescribe("获取PPI工业生产者出厂价格指数数据");

        HashMap<String,String> paramsMap = new HashMap<>();
        paramsMap.put("start_m","200001");
        //paramsMap.put("end_m",DateUtils.lastTUMonthString());
        request.setParams(paramsMap);

        LinkedHashMap<String,String> fieldMap = new LinkedHashMap<>();
        fieldMap.put("month","月份YYYYMM");
        fieldMap.put("ppi_yoy","PPI：全部工业品：当月同比");
        fieldMap.put("ppi_mp_yoy","PPI：生产资料：当月同比");
        fieldMap.put("ppi_mp_qm_yoy","PPI：生产资料：采掘业：当月同比");
        fieldMap.put("ppi_mp_rm_yoy","PPI：生产资料：原料业：当月同比");
        fieldMap.put("ppi_mp_p_yoy","PPI：生产资料：加工业：当月同比");
        fieldMap.put("ppi_cg_yoy","PPI：生活资料：当月同比");
        fieldMap.put("ppi_cg_f_yoy","PPI：生活资料：食品类：当月同比");
        fieldMap.put("ppi_cg_c_yoy","PPI：生活资料：衣着类：当月同比");
        fieldMap.put("ppi_cg_adu_yoy","PPI：生活资料：一般日用品类：当月同比");
        fieldMap.put("ppi_cg_dcg_yoy","PPI：生活资料：耐用消费品类：当月同比");
        fieldMap.put("ppi_mom","PPI：全部工业品：环比");
        fieldMap.put("ppi_mp_mom","PPI：生产资料：环比");
        fieldMap.put("ppi_mp_qm_mom","PPI：生产资料：采掘业：环比");
        fieldMap.put("ppi_mp_rm_mom","PPI：生产资料：原料业：环比");
        fieldMap.put("ppi_mp_p_mom","PPI：生产资料：加工业：环比");
        fieldMap.put("ppi_cg_mom","PPI：生活资料：环比");
        fieldMap.put("ppi_cg_f_mom","PPI：生活资料：食品类：环比");
        fieldMap.put("ppi_cg_c_mom","PPI：生活资料：衣着类：环比");
        fieldMap.put("ppi_cg_adu_mom","PPI：生活资料：一般日用品类：环比");
        fieldMap.put("ppi_cg_dcg_mom","PPI：生活资料：耐用消费品类：环比");
        fieldMap.put("ppi_accu","PPI：全部工业品：累计同比");
        fieldMap.put("ppi_mp_accu","PPI：生产资料：累计同比");
        fieldMap.put("ppi_mp_qm_accu","PPI：生产资料：采掘业：累计同比");
        fieldMap.put("ppi_mp_rm_accu","PPI：生产资料：原料业：累计同比");
        fieldMap.put("ppi_mp_p_accu","PPI：生产资料：加工业：累计同比");
        fieldMap.put("ppi_cg_accu","PPI：生活资料：累计同比");
        fieldMap.put("ppi_cg_f_accu","PPI：生活资料：食品类：累计同比");
        fieldMap.put("ppi_cg_c_accu","PPI：生活资料：衣着类：累计同比");
        fieldMap.put("ppi_cg_adu_accu","PPI：生活资料：一般日用品类：累计同比");
        fieldMap.put("ppi_cg_dcg_accu","PPI：生活资料：耐用消费品类：累计同比");
        request.setFieldMap(fieldMap);
        setRequest(request);
    }

    public static void main(String[] args) {
        new PPI(new TuClient(Config.url, Config.token))
                .get().ifPresent(System.out::println);
    }
}
